package com.webbei.shoppingCar.action;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.webbei.shoppingCar.service.shoppingCarService;

public class changPasswordAction {
	private String password;
	private String oldpassword;
	private String result;
	private shoppingCarService scs;
	public String execute(){
		String username=(String) ServletActionContext.getContext().getSession().get("username");
		Map m=new HashMap();
		m.put("password", oldpassword);
		m.put("name", username);
		Integer re=scs.checkUserPassword(m);
		if(re!=1){
			result="1";
			return "success";
		}else{
			Map<String, String> map=new HashMap<String, String>();
			map.put("password", password);
			map.put("name", username);
			scs.changeUserPassword(map);
			result="2";
			return "success";
		}
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getOldpassword() {
		return oldpassword;
	}

	public void setOldpassword(String oldpassword) {
		this.oldpassword = oldpassword;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public void setScs(shoppingCarService scs) {
		this.scs = scs;
	}
}
